
/************************************************************/
/************************************************************/
/* Reproduce Figures and Tables from main body of the paper */
/************************************************************/
/************************************************************/


clear
clear matrix 
clear mata
*global folder "E:\Dropbox\Boycott\STATA Files\Replication QJE"
global folder "C:\Users\WALDINGE\Dropbox\Research Project 17 - Death of International Science\Sharing\STATA Files\Replication QJE"
set more off
set maxvar 32000

graph set window fontface "Segoe UI"



/*****************************************************/
/* FIGURE I: Arrival Delay of International Journals */
/*****************************************************/

use "$folder\Dataset_1.dta", clear

/* Panel (a) */

#delimit ;
graph twoway scatter  harvard_difference year if journal=="ZfaC", msymbol(Sh) connect(line) color("193 5 52") text(-40 1927.5 "Z f a Chemie", place(e) color("193 5 52") justification(left))
	|| scatter harvard_difference year if journal=="AdP", xline(1914, lcolor(black)) msymbol(S) connect(line) color("144 53 59") text(-10 1927.5 "Ann d Phys", place(e) color("144 53 59") justification(left))
	legend(off) yscale(range(-800 0)) ytick(-800(200)0) ylabel(-800(200)0, nogrid)  ytitle("Arrival delay in days") xtitle("") graphregion(color(white)) xline(1914, lcolor(black)); 
	
/* Panel (b) */

#delimit ;
graph twoway scatter  harvard_difference year if journal=="N", msymbol(Th) connect(line) color("130 192 233") text(-19.5 1927.5 "Nature", place(e) color("130 192 233") justification(left)) 
	|| scatter harvard_difference year if journal=="CR", msymbol(Th) connect(line) color("26 71 111") text(-22.5 1927.5 "Comp. Rend.", place(e) color("26 71 111") justification(left)) 
	legend(off) yscale(range(-60 0)) ytick(-60(20)0) ylabel(-60(20)0, nogrid)  ytitle("Arrival delay in days") xtitle("") graphregion(color(white)) xline(1914, lcolor(black)); 

/* Panel (c) */

***Collapse Allied and Central journals
gen block = "Central" if journal=="ZfaC" | journal=="AdP"
replace block = "Allied" if journal=="N" | journal=="CR"
collapse (mean) harvard_difference harvard_difference_tc, by(block year) 
	
#delimit ;
graph twoway scatter harvard_difference year if block=="Central", xline(1914, lcolor(black)) msymbol(S) connect(line) color("144 53 59") text(-40 1927.5 "Central", place(e) color("144 53 59") justification(left))
	|| scatter harvard_difference year if block=="Allied", msymbol(Th) connect(line) color("26 71 111") text(-15 1927.5 "Allied", place(e) color("26 71 111") justification(left)) 
	legend(off) yscale(range(-800 0)) ytick(-800(200)0) ylabel(-800(200)0, nogrid)  ytitle("Arrival delay in days") xtitle("") graphregion(color(white)) xline(1914, lcolor(black)); 

/* Panel (d) */

use "$folder\Dataset_2.dta", clear

#delimit ;
graph twoway scatter  harvard_difference year, msymbol(S) mcolor("144 53 59") connect(line) color("144 53 59") text(-40 1927.5 "Harvard", place(e) color("144 53 59"))
	|| scatter  heidelberg_difference year, msymbol(circle) connect(line) color("193 5 52") text(-0 1927.5 "Heidelberg", place(e) color("193 5 52"))
	legend(off) yscale(range(-800 0)) ytick(-800(200)0) ylabel(-800(200)0, nogrid)  ytitle("Arrival delay in days") xtitle("") graphregion(color(white)) xline(1914, lcolor(black)); 

	
	
/*************************************************************/
/* FIGURE IV: International Citation Shares Relative to Home */
/*************************************************************/


use "$folder\Dataset_3_top1.dta", clear
xtset paper_group

xtreg c5s_cntns_all_ PY_FOIN_1905-PY_FOIN_1930 PY_FOUT_1905-PY_FOUT_1930 /// 
      if (AU_all_central_strict==1 | AU_all_allies_strict==1) & (PY>=1905 & PY<1931) /// 
	  & (foreign=="HOME" | foreign=="FOIN" | foreign=="FOUT"), fe cl(country_journalspec_all)


	  
/************************************************************************************************/
/* FIGURE V: International Citation Shares Relative to Home: Citations to High Quality Research */
/************************************************************************************************/
	  
/* Panel (a) */	  

use "$folder\Dataset_3_top5.dta", clear
xtset paper_group	  

xtreg c5s_cntns_all_ PY_FOIN_H_1905-PY_FOIN_H_1930 PY_FOIN_L_1905-PY_FOIN_L_1930 PY_FOUT_H_1905-PY_FOUT_H_1930 PY_FOUT_L_1905-PY_FOUT_L_1930 PY_HOME_L_1905-PY_HOME_L_1930 /// 
      if (AU_all_central_strict==1 | AU_all_allies_strict==1) & (PY>=1905 & PY<1931) /// 
	  & (foreign=="HOME_H" | foreign=="HOME_L" | foreign=="FOIN_H" | foreign=="FOIN_L" | foreign=="FOUT_H" | foreign=="FOUT_L"), fe cl(country_journalspec_all)


/* Panel (b) */

use "$folder\Dataset_3_top3.dta", clear
xtset paper_group  

xtreg c5s_cntns_all_ PY_FOIN_H_1905-PY_FOIN_H_1930 PY_FOIN_L_1905-PY_FOIN_L_1930 PY_FOUT_H_1905-PY_FOUT_H_1930 PY_FOUT_L_1905-PY_FOUT_L_1930 PY_HOME_L_1905-PY_HOME_L_1930 /// 
      if (AU_all_central_strict==1 | AU_all_allies_strict==1) & (PY>=1905 & PY<1931) /// 
	  & (foreign=="HOME_H" | foreign=="HOME_L" | foreign=="FOIN_H" | foreign=="FOIN_L" | foreign=="FOUT_H" | foreign=="FOUT_L"), fe cl(country_journalspec_all)

	  
/* Panel (c) */

use "$folder\Dataset_3_top1.dta", clear
xtset paper_group
	  
xtreg c5s_cntns_all_ PY_FOIN_H_1905-PY_FOIN_H_1930 PY_FOIN_L_1905-PY_FOIN_L_1930 PY_FOUT_H_1905-PY_FOUT_H_1930 PY_FOUT_L_1905-PY_FOUT_L_1930 PY_HOME_L_1905-PY_HOME_L_1930 /// 
      if (AU_all_central_strict==1 | AU_all_allies_strict==1) & (PY>=1905 & PY<1931) /// 
	  & (foreign=="HOME_H" | foreign=="HOME_L" | foreign=="FOIN_H" | foreign=="FOIN_L" | foreign=="FOUT_H" | foreign=="FOUT_L"), fe cl(country_journalspec_all)
	  
	  




/********************************************************************************************/
/* FIGURE VI: International Citation Shares Relative to Home: Citations to Pre-War Research */
/********************************************************************************************/

/* Panel (a) */

use "$folder\Dataset_4_1903.dta", clear
xtset paper_group

xtreg c31903s_cntns_all_ PY_FOIN_1905-PY_FOIN_1930 PY_FOUT_1905-PY_FOUT_1930 /// 
      if (AU_all_central_strict==1 | AU_all_allies_strict==1) & (PY>=1905 & PY<1931) /// 
	  & (foreign=="HOME" | foreign=="FOIN" | foreign=="FOUT"), fe cl(country_journalspec_all)

/* Panel (b) */

use "$folder\Dataset_4_1911.dta", clear
xtset paper_group

xtreg c31911s_cntns_all_ PY_FOIN_1905-PY_FOIN_1930 PY_FOUT_1905-PY_FOUT_1930 /// 
      if (AU_all_central_strict==1 | AU_all_allies_strict==1) & (PY>=1911 & PY<1931) /// 
	  & (foreign=="HOME" | foreign=="FOIN" | foreign=="FOUT"), fe cl(country_journalspec_all)



/***************************************************************/
/* FIGURE VII: International Title Similarity Relative to Home */
/***************************************************************/


/* Panel (a) */

use "$folder\Dataset_5.dta", clear
xtset paper_group

xtreg LSA_500_sim_max_std PY_FOIN_1905-PY_FOIN_1930 PY_FOUT_1905-PY_FOUT_1930 /// 
      if (AU_all_central_strict==1 | AU_all_allies_strict==1) & (PY>=1905 & PY<1931) /// 
	  & (foreign=="HOME" | foreign=="FOIN" | foreign=="FOUT") & sample_main_AL_CE == 1, fe cl(country_journalspec_all)

/* Panel (b) */

use "$folder\Dataset_5.dta", clear
xtset paper_group

xtreg LSA_500_sim_avg5_std PY_FOIN_1905-PY_FOIN_1930 PY_FOUT_1905-PY_FOUT_1930 /// 
      if (AU_all_central_strict==1 | AU_all_allies_strict==1) & (PY>=1905 & PY<1931) /// 
	  & (foreign=="HOME" | foreign=="FOIN" | foreign=="FOUT") & sample_main_AL_CE == 1, fe cl(country_journalspec_all)

	
	
	  
/***********************************************************************************************/
/* FIGURE VIII: Pre-War Citations to Research from Home, Foreign Inside Camp, and Outside Camp */
/***********************************************************************************************/
	  
use "$folder\Dataset_6.dta", clear

/* Panel (a) */

graph hbar c0013s_mnva_FOUT c0013s_mnva_FOIN  c0013s_mnva_HO_  ///
	if country_field!="Italy:  Biology/Medicine" & country_field!="Canada:  Chemistry" & country_field!="Austria:  Biochemistry"  & country_field!="France:  General Science" ///
	& country_field!="France:  Physics" & country_field!="Ireland:  Biochemistry" & country_field!="Hungary:  Phys. Chemistry" & country_field!="Japan:  Chemistry" /// 
	,  stack over(country_field, sort(order)  descending)  xsize(7) ysize(15)  xalternate  ///
	bar(1,color(black) lcolor(gs4)) bar(2,color(gs7) lcolor(gs4))  bar(3,color(gs15) lcolor(gs4)) ///
	legend(label(1 "Foreign citations outside") label(2 "Foreign citations inside") label(3 "Home citations") cols(1) region(lwidth(none)))  graphregion(color(white)) ///
	title("All Research", color(black)) ylabel(0(0.2)1, nogrid)
	
/* Panel (b) */

graph hbar c0013s_mnva_FOUT_HH c0013s_mnva_FOIN_HH  c0013s_mnva_HO_HH   ///
	if country_field!="Italy:  Biology/Medicine" & country_field!="Canada:  Chemistry" & country_field!="Austria:  Biochemistry"  & country_field!="France:  General Science" ///
	& country_field!="France:  Physics" & country_field!="Ireland:  Biochemistry" & country_field!="Hungary:  Phys. Chemistry" & country_field!="Japan:  Chemistry" ///	
	,  stack over(country_field, sort(order)  descending)  xsize(7) ysize(15)  ///
	bar(1,color(black) lcolor(gs4)) bar(2,color(gs7) lcolor(gs4))  bar(3,color(gs15) lcolor(gs4)) ///
	legend(label(1 "Foreign citations outside") label(2 "Foreign citations inside") label(3 "Home citations") cols(1) region(lwidth(none)))  graphregion(color(white)) ///
	title("Frontier Research", color(black)) ylabel(0(0.2)1, nogrid)

	

	
/*************************************/
/* FIGURE IX: Effect on Publications */
/*************************************/
	  
use "$folder\Dataset_7_part1_top1.dta", clear
	
areg pubn_rdc_std FOUT_H_reliance_mnva_L1905-FOUT_H_reliance_mnva_L1930 FOIN_H_reliance_mnva_L1905-FOIN_H_reliance_mnva_L1930 ///
				FOUT_L_reliance_mnva_L1905-FOUT_L_reliance_mnva_L1930 FOIN_L_reliance_mnva_L1905-FOIN_L_reliance_mnva_L1930 ///
				HOME_L_reliance_mnva_L1905-HOME_L_reliance_mnva_L1930 career_age5_*_d? PY_d? PY_d?? if AU_block_mnva!="RE" & AU_block_mnva!="NE", a(id) cl(cluster_foreign)				
	
	
/***********************************************************/
/* FIGURE X: Effect on Publications: Within U.S. Variation */
/***********************************************************/
	  
use "$folder\Dataset_7_part1_top1.dta", clear
	
areg pubn_rdc_std FOUT_H_reliance_mnva_L1905-FOUT_H_reliance_mnva_L1930 FOIN_H_reliance_mnva_L1905-FOIN_H_reliance_mnva_L1930 ///
				FOUT_L_reliance_mnva_L1905-FOUT_L_reliance_mnva_L1930 FOIN_L_reliance_mnva_L1905-FOIN_L_reliance_mnva_L1930 ///
				HOME_L_reliance_mnva_L1905-HOME_L_reliance_mnva_L1930 career_age5_*_d? PY_d? PY_d?? if AU_block_mnva!="RE" & AU_block_mnva!="NE" & AU_country_mnva=="USA", a(id) cl(cluster_foreign)				

	  
	 
	 
	 
	 
/*****************************************************************************************/
/* TABLE III: Summary Statistics: International Citation Shares and LSA Title Similarity */
/*****************************************************************************************/


/***********/
/* Panel A */
/***********/


foreach percentile in  "1" "3" "5" {

cd "$folder\"
use Dataset_3_top`percentile'.dta, clear

* num of papers
gen paper_count = 0
bys J9 paper_id: replace paper_count = 1 if _n==1
  
* num of refereces
bys J9 paper_id: egen refer_count = total(c5_cntns_all_) if foreign=="HOME" | foreign=="FOIN" | foreign=="FOUT"
bys J9 paper_id: egen num_ref = max(refer_count)
drop refer_count

bys J9 paper_id: egen refer_count_H = total(c5_cntns_all_) if foreign=="HOME_H" | foreign=="FOIN_H" | foreign=="FOUT_H"
bys J9 paper_id: egen num_ref_H = max(refer_count_H)
drop refer_count_H

* share of HOME references
gen sh_HOME = 0
bys J9 paper_id: replace sh_HOME = c5s_cntns_all_ if foreign == "HOME"
bys J9 paper_id: egen share_HOME = max(sh_HOME)	  
drop sh_HOME

* share of HOME_H references
gen sh_HOME = 0
bys J9 paper_id: replace sh_HOME = c5s_cntns_all_ if foreign == "HOME_H"
bys J9 paper_id: egen share_HOME_H = max(sh_HOME)	  
drop sh_HOME

* share of FOIN references
gen sh_FOIN = 0
bys J9 paper_id: replace sh_FOIN = c5s_cntns_all_ if foreign == "FOIN"
bys J9 paper_id: egen share_FOIN = max(sh_FOIN)	  
drop sh_FOIN

* share of FOIN_H references
gen sh_FOIN = 0
bys J9 paper_id: replace sh_FOIN = c5s_cntns_all_ if foreign == "FOIN_H"
bys J9 paper_id: egen share_FOIN_H = max(sh_FOIN)	  
drop sh_FOIN

* share of FOUT references
gen sh_FOUT = 0
bys J9 paper_id: replace sh_FOUT = c5s_cntns_all_ if foreign == "FOUT"
bys J9 paper_id: egen share_FOUT = max(sh_FOUT)	  
drop sh_FOUT

* share of FOUT_H references
gen sh_FOUT = 0
bys J9 paper_id: replace sh_FOUT = c5s_cntns_all_ if foreign == "FOUT_H"
bys J9 paper_id: egen share_FOUT_H = max(sh_FOUT)	  
drop sh_FOUT

* one observation per paper
keep if paper_count == 1
drop foreign

gen x = 1 
collapse (sum) paper_count num_ref num_ref_H (mean) share_HOME share_FOIN share_FOUT share_HOME_H share_FOIN_H share_FOUT_H, by(x)

gen av_cit_rec_res = num_ref/paper_count
gen av_cit_rec_res_H = num_ref_H/paper_count

drop paper_count num_ref num_ref_H x
order av_cit_rec_res av_cit_rec_res_H

/*
The resulting data correspond to:
   (1) the first row of Panel A (for any `percentile')
   (2) the row of Panel A corresponding to `percentile'
*/

} /* percentile */



/***********/
/* Panel B */
/***********/

use "$folder\Dataset_5.dta", clear
xtset paper_group


foreach depend in  "avg5" "max" {	
 	 
* LSA of HOME references
gen LSA_500_`depend'_HOME = -999999999
bys J9 paper_id: replace LSA_500_`depend'_HOME = LSA_500_sim_`depend'_std if foreign == "HOME"
bys J9 paper_id: egen LSA_500_sim_`depend'_HOME = max(LSA_500_`depend'_HOME)	  
drop LSA_500_`depend'_HOME

* LSA of FOIN references
gen LSA_500_`depend'_FOIN = -999999999
bys J9 paper_id: replace LSA_500_`depend'_FOIN = LSA_500_sim_`depend'_std if foreign == "FOIN"
bys J9 paper_id: egen LSA_500_sim_`depend'_FOIN = max(LSA_500_`depend'_FOIN)	  
drop LSA_500_`depend'_FOIN

* LSA of FOUT references
gen LSA_500_`depend'_FOUT = -999999999
bys J9 paper_id: replace LSA_500_`depend'_FOUT = LSA_500_sim_`depend'_std if foreign == "FOUT"
bys J9 paper_id: egen LSA_500_sim_`depend'_FOUT = max(LSA_500_`depend'_FOUT)	  
drop LSA_500_`depend'_FOUT

} /* depend */


* one observation per paper
gen paper_count = 0
bys J9 paper_id: replace paper_count = 1 if _n==1

keep if paper_count == 1
drop foreign LSA_500_sim_*_std

gen x = 1 
collapse (sum) paper_count (mean) LSA_500_sim_*_HOME LSA_500_sim_*_FOIN LSA_500_sim_*_FOUT, by(x)
drop paper_count x

/* The resulting data correspond to Panel B */


	  
	  
/************************************************/
/* TABLE IV: Changes in International Citations */
/************************************************/

/* Column (1) */

use "$folder\Dataset_3_top1.dta", clear
xtset paper_group

xtreg c5s_cntns_all_ CR_FOUT FOUT_post ///
	  CR_FOIN FOIN_post ///
      if (AU_all_central_strict==1 | AU_all_allies_strict==1) & (PY>=1905 & PY<1931) /// 
	  & (foreign=="HOME" | foreign=="FOIN" | foreign=="FOUT"), fe cl(country_journalspec_all)

/* Column (2) */

use "$folder\Dataset_3_top1.dta", clear
xtset paper_group

xtreg c5s_cntns_all_ CR_FOUT FOUT_post ///
	  CR_FOIN FOIN_post PY_trend_FOUT PY_trend_FOIN ///
      if (AU_all_central_strict==1 | AU_all_allies_strict==1) & (PY>=1905 & PY<1931) /// 
	  & (foreign=="HOME" | foreign=="FOIN" | foreign=="FOUT"), fe cl(country_journalspec_all)

/* Column (3) */

use "$folder\Dataset_3_top1.dta", clear
xtset paper_group

xtreg c5s_cntns_all_ CR_FOUT FOUT_ww1 FOUT_bct FOUT_postbct ///
	  CR_FOIN FOIN_ww1 FOIN_bct FOIN_postbct ///
      if (AU_all_central_strict==1 | AU_all_allies_strict==1) & (PY>=1905 & PY<1931) /// 
	  & (foreign=="HOME" | foreign=="FOIN" | foreign=="FOUT"), fe cl(country_journalspec_all)	

/* Column (4) */

use "$folder\Dataset_3_top1.dta", clear
xtset paper_group

xtreg c5s_cntns_all_ CR_FOUT FOUT_ww1 FOUT_bct FOUT_postbct ///
	  CR_FOIN FOIN_ww1 FOIN_bct FOIN_postbct ///
	  PY_trend_FOUT PY_trend_FOIN ///
      if (AU_all_central_strict==1 | AU_all_allies_strict==1) & (PY>=1905 & PY<1931) /// 
	  & (foreign=="HOME" | foreign=="FOIN" | foreign=="FOUT"), fe cl(country_journalspec_all)	



/******************************************************************/
/* TABLE V: Changes in International Citations: Frontier Research */
/******************************************************************/

foreach percentile in  "5" "3" "1" {

cd "$folder\"
use Dataset_3_top`percentile'.dta, clear

xtset paper_group
	
/* Column (1), (3), and (5) */
	
xtreg c5s_cntns_all_ CR_FOUT_H FOUT_H_post CR_FOUT_L FOUT_L_post  ///
					 CR_FOIN_H FOIN_H_post CR_FOIN_L FOIN_L_post /// 
                     CR_HOME_L HOME_L_post /// 
      if (AU_all_central_strict==1 | AU_all_allies_strict==1) & (PY>=1905 & PY<1931) /// 
	  & (foreign=="HOME_H" | foreign=="HOME_L" | foreign=="FOIN_H" | foreign=="FOIN_L" | foreign=="FOUT_H" | foreign=="FOUT_L"), fe cl(country_journalspec_all)

		
/* Column (2), (4), and (6) */

xtreg c5s_cntns_all_ CR_FOUT_H FOUT_H_post CR_FOUT_L FOUT_L_post  ///
					 CR_FOIN_H FOIN_H_post CR_FOIN_L FOIN_L_post /// 
                     CR_HOME_L HOME_L_post ///
					 PY_trend_FOUT_H PY_trend_FOIN_H PY_trend_FOUT_L PY_trend_FOIN_L PY_trend_HOME_L /// 						
      if (AU_all_central_strict==1 | AU_all_allies_strict==1) & (PY>=1905 & PY<1931) /// 
	  & (foreign=="HOME_H" | foreign=="HOME_L" | foreign=="FOIN_H" | foreign=="FOIN_L" | foreign=="FOUT_H" | foreign=="FOUT_L"), fe cl(country_journalspec_all)
	
} /* percentile */


/******************************************************************************/
/* TABLE VI: The Similarity of Papers as Measured by Latent Semantic Analysis */
/******************************************************************************/


use "$folder\Dataset_5.dta", clear
xtset paper_group


foreach depend in "max_std" "avg5_std" {

/* Column (1) and (5) */
xtreg LSA_500_sim_`depend' CR_FOUT FOUT_post ///
	  CR_FOIN FOIN_post ///
      if (AU_all_central_strict==1 | AU_all_allies_strict==1) & (PY>=1905 & PY<1931) /// 
	  & (foreign=="HOME" | foreign=="FOIN" | foreign=="FOUT") & sample_main_AL_CE == 1, fe cl(country_journalspec_all)

/* Column (2) and (6) */

xtreg LSA_500_sim_`depend' CR_FOUT FOUT_post ///
	  CR_FOIN FOIN_post PY_trend_FOUT PY_trend_FOIN ///
      if (AU_all_central_strict==1 | AU_all_allies_strict==1) & (PY>=1905 & PY<1931) /// 
	  & (foreign=="HOME" | foreign=="FOIN" | foreign=="FOUT") & sample_main_AL_CE == 1, fe cl(country_journalspec_all)

/* Column (3) and (7) */
	
xtreg LSA_500_sim_`depend' CR_FOUT FOUT_ww1 FOUT_bct FOUT_postbct ///
	  CR_FOIN FOIN_ww1 FOIN_bct FOIN_postbct ///
      if (AU_all_central_strict==1 | AU_all_allies_strict==1) & (PY>=1905 & PY<1931) /// 
	  & (foreign=="HOME" | foreign=="FOIN" | foreign=="FOUT") & sample_main_AL_CE == 1, fe cl(country_journalspec_all)

/* Column (4) and (8) */
	  
xtreg LSA_500_sim_`depend' CR_FOUT FOUT_ww1 FOUT_bct FOUT_postbct ///
	  CR_FOIN FOIN_ww1 FOIN_bct FOIN_postbct ///
	  PY_trend_FOUT PY_trend_FOIN ///
      if (AU_all_central_strict==1 | AU_all_allies_strict==1) & (PY>=1905 & PY<1931) /// 
	  & (foreign=="HOME" | foreign=="FOIN" | foreign=="FOUT") & sample_main_AL_CE == 1, fe cl(country_journalspec_all)

} /* depend */



/*************************************************************/
/* TABLE VII: Summary Statistics: Productivity of Scientists */
/*************************************************************/


use "$folder\Dataset_7_part1_top1.dta", clear

/* Number of scientists (Obs) */

sum AU_ident if PY==1913

/* Number of scientist-year observations (Obs) */

sum AU_ident

/* Career age in years */

gen career_age0 = career_age
replace career_age0 = 0 if career_age<0
sum career_age0

/* Publications per year */

sum pubn_rdc_

/* Nobel-nominated papers per year */

sum nom_paper1_belast

/* Nomination weighted Nobel-nominated papers per year */

sum nom_paper1_belast_last2

/* Number of novel words (word innovation) per year */

sum pubn_wiw_rdc_

/* Patent relevant word innovation per year */

sum pubn_wip_rdc_tot_99th_




/**************************************/
/* TABLE VIII: Effect on Publications */
/**************************************/

foreach percentile in  "1" "3" "5" {

cd "$folder\"
use Dataset_7_part1_top`percentile'.dta, clear

xtset id 
xtreg pubn_rdc_std FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST  FOIN_L_reliance_mnva_L_POST  HOME_L_reliance_mnva_L_POST ///
				   career_age5_*_d? PY_d? PY_d?? if AU_block_mnva!="RE" & AU_block_mnva!="NE", fe cl(cluster_foreign)

} /* percentile */



/*******************************************************/
/* TABLE IX: Effect on Publications: Robustness Checks */
/*******************************************************/


foreach percentile in  "1" "3" "5" {

cd "$folder\"
use Dataset_7_part1_top`percentile'.dta, clear

/* Column (1) - Panel A, B, and C */

xtset id 
xtreg pubn_rdc_std FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST  FOIN_L_reliance_mnva_L_POST  HOME_L_reliance_mnva_L_POST ///
				   career_age5_*_d? PY_d? PY_d?? if AU_block_mnva!="RE" & AU_block_mnva!="NE", fe cl(cluster_foreign)

/* Column (2) - Panel A, B, and C */

xtset id 
xtreg pub_rdc_std FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST  FOIN_L_reliance_mnva_L_POST  HOME_L_reliance_mnva_L_POST ///
				  career_age5_*_d? PY_d? PY_d?? if AU_block_mnva!="RE" & AU_block_mnva!="NE", fe cl(cluster_foreign)
				  		   
/* Column (3) - Panel A, B, and C */

xtset id 
xtreg pubn_rdc_std FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST  FOIN_L_reliance_mnva_L_POST  HOME_L_reliance_mnva_L_POST ///
                   career_age5_*_d? PY_d? PY_d?? PY_d?_AL PY_d??_AL if AU_block_mnva!="RE" & AU_block_mnva!="NE", fe cl(cluster_foreign)
				   
/* Column (4) - Panel A, B, and C */

set matsize 5000		   
xtset id 
xtreg pubn_rdc_std FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST  FOIN_L_reliance_mnva_L_POST  HOME_L_reliance_mnva_L_POST ///
				   career_age5_*_d? main_field_foreign_d?_19?? main_field_foreign_d??_19?? if AU_block_mnva!="RE" & AU_block_mnva!="NE", fe cl(cluster_foreign)

/* Column (5) - Panel A, B, and C */

set matsize 5000		   		   
xtset id 
xtreg pubn_rdc_std FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST  FOIN_L_reliance_mnva_L_POST  HOME_L_reliance_mnva_L_POST ///
				   career_age5_*_d? main_field_foreign_d?_19?? main_field_foreign_d??_19?? main_field_foreign_d?_19??_AL main_field_foreign_d??_19??_AL if AU_block_mnva!="RE" & AU_block_mnva!="NE", fe cl(cluster_foreign)			   
				   
} /* percentile */




/****************************************************************************************************/
/* TABLE X: Effect on Publications: Disruption of Knowledge Flows or Other War Re-lated Disruption? */
/****************************************************************************************************/


foreach percentile in  "1" "3" "5" {

cd "$folder\"
use Dataset_7_part1_top`percentile'.dta, clear

/* Column (1) - Panel A, B, and C */

set matsize 5000		   
xtset id 
xtreg pubn_rdc_std FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST  FOIN_L_reliance_mnva_L_POST  HOME_L_reliance_mnva_L_POST ///
				   career_age5_*_d? main_field_foreign_d?_19?? main_field_foreign_d??_19?? main_field_foreign_d?_19??_AL main_field_foreign_d??_19??_AL combat_y19?? if AU_block_mnva!="RE" & AU_block_mnva!="NE", fe cl(cluster_foreign)

/* Column (2) - Panel A, B, and C */

set matsize 5000		   
xtset id 
xtreg pub_rdc_std FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST  FOIN_L_reliance_mnva_L_POST  HOME_L_reliance_mnva_L_POST ///
				  career_age5_*_d? main_field_foreign_d?_19?? main_field_foreign_d??_19?? main_field_foreign_d?_19??_AL main_field_foreign_d??_19??_AL deaths_pp_reperes_y19?? if AU_block_mnva!="RE" & AU_block_mnva!="NE", fe cl(cluster_foreign)
				  		   
/* Column (3) - Panel A, B, and C */

set matsize 5000		   
xtset id 
xtreg pubn_rdc_std FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST  FOIN_L_reliance_mnva_L_POST  HOME_L_reliance_mnva_L_POST ///
				   career_age5_*_d? main_field_foreign_d?_19?? main_field_foreign_d??_19?? main_field_foreign_d?_19??_AL main_field_foreign_d??_19??_AL civ_deaths_pp_reperes_y19?? if AU_block_mnva!="RE" & AU_block_mnva!="NE", fe cl(cluster_foreign)
				   
/* Column (4) - Panel A, B, and C */
			
set matsize 5000
xtset id 
xtreg pubn_rdc_std FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST  FOIN_L_reliance_mnva_L_POST  HOME_L_reliance_mnva_L_POST ///
				   career_age5_*_d? main_field_foreign_d?_19?? main_field_foreign_d??_19?? main_field_foreign_d?_19??_AL main_field_foreign_d??_19??_AL combat_y19?? deaths_pp_reperes_y19?? civ_deaths_pp_reperes_y19?? if AU_block_mnva!="RE" & AU_block_mnva!="NE", fe cl(cluster_foreign)

/* Column (5) - Panel A, B, and C */

set matsize 5000		   
xtset id 
xtreg pubn_rdc_std FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST  FOIN_L_reliance_mnva_L_POST  HOME_L_reliance_mnva_L_POST ///
				   career_age5_*_d? main_field_foreign_d?_19?? main_field_foreign_d??_19?? main_field_foreign_d?_19??_AL main_field_foreign_d??_19??_AL if AU_block_mnva!="RE" & AU_block_mnva!="NE" & main_field_foreign != "Chem", fe cl(cluster_foreign)

/* Column (6) - Panel A, B, and C */

cd "$folder\"
use Dataset_7_part2_top`percentile'.dta, clear

set matsize 5000		   
xtset id 
xtreg pubn_rdc_std FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST FOIN_L_reliance_mnva_L_POST HOME_L_reliance_mnva_L_POST ///
				   career_age5_*_d? main_field_foreign_d?_19?? main_field_foreign_d??_19?? main_field_foreign_d?_19??_AL main_field_foreign_d??_19??_AL if AU_block_mnva!="RE" & AU_block_mnva!="NE", fe cl(cluster_foreign)
		   
} /* percentile */




/**********************************************/
/* TABLE XI: Effect on Nobel-Nominated Papers */
/**********************************************/

foreach percentile in  "1" "3" "5" {

cd "$folder\"
use Dataset_7_part1_top`percentile'.dta, clear

/* Column (1) - Panel A, B, and C */

xtset id 
xtreg nom_paper1_belast FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST  FOIN_L_reliance_mnva_L_POST  HOME_L_reliance_mnva_L_POST ///
						career_age5_*_d? PY_d? PY_d?? if AU_block_mnva!="RE" & AU_block_mnva!="NE", fe cl(cluster_foreign)

/* Column (2) - Panel A, B, and C */
				   
set matsize 5000		   
xtset id 
xtreg nom_paper1_belast FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST FOIN_L_reliance_mnva_L_POST HOME_L_reliance_mnva_L_POST ///
					    career_age5_*_d? main_field_foreign_d?_19?? main_field_foreign_d??_19?? main_field_foreign_d?_19??_AL main_field_foreign_d??_19??_AL if AU_block_mnva!="RE" & AU_block_mnva!="NE", fe cl(cluster_foreign)
	   
/* Column (3) - Panel A, B, and C */

xtset id 
xtreg nom_paper1_belast_last2 FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST  FOIN_L_reliance_mnva_L_POST  HOME_L_reliance_mnva_L_POST ///
						      career_age5_*_d? PY_d? PY_d?? if AU_block_mnva!="RE" & AU_block_mnva!="NE", fe cl(cluster_foreign)

/* Column (4) - Panel A, B, and C */
				   
set matsize 5000		   
xtset id 
xtreg nom_paper1_belast_last2 FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST FOIN_L_reliance_mnva_L_POST HOME_L_reliance_mnva_L_POST ///
					          career_age5_*_d? main_field_foreign_d?_19?? main_field_foreign_d??_19?? main_field_foreign_d?_19??_AL main_field_foreign_d??_19??_AL if AU_block_mnva!="RE" & AU_block_mnva!="NE", fe cl(cluster_foreign)
		      
} /* percentile */




/****************************************************/
/* TABLE XII: Effect on Word Innovation and Patents */
/****************************************************/

foreach percentile in  "1" "3" "5" {

cd "$folder\"
use Dataset_7_part1_top`percentile'.dta, clear

/* Column (1) - Panel A, B, and C */

xtset id 
xtreg pubn_wiw_rdc_std FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST  FOIN_L_reliance_mnva_L_POST  HOME_L_reliance_mnva_L_POST ///
					   career_age5_*_d? PY_d? PY_d?? if AU_block_mnva!="RE" & AU_block_mnva!="NE", fe cl(cluster_foreign)

/* Column (2) - Panel A, B, and C */
				   
set matsize 5000		   
xtset id 
xtreg pubn_wiw_rdc_std FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST FOIN_L_reliance_mnva_L_POST HOME_L_reliance_mnva_L_POST ///
					   career_age5_*_d? main_field_foreign_d?_19?? main_field_foreign_d??_19?? main_field_foreign_d?_19??_AL main_field_foreign_d??_19??_AL if AU_block_mnva!="RE" & AU_block_mnva!="NE", fe cl(cluster_foreign)
	   
/* Column (3) - Panel A, B, and C */

xtset id 
xtreg pubn_wip_rdc_tot_99th_std FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST  FOIN_L_reliance_mnva_L_POST  HOME_L_reliance_mnva_L_POST ///
						        career_age5_*_d? PY_d? PY_d?? if AU_block_mnva!="RE" & AU_block_mnva!="NE", fe cl(cluster_foreign)

/* Column (4) - Panel A, B, and C */
				   
set matsize 5000		   
xtset id 
xtreg pubn_wip_rdc_tot_99th_std FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST FOIN_L_reliance_mnva_L_POST HOME_L_reliance_mnva_L_POST ///
					            career_age5_*_d? main_field_foreign_d?_19?? main_field_foreign_d??_19?? main_field_foreign_d?_19??_AL main_field_foreign_d??_19??_AL if AU_block_mnva!="RE" & AU_block_mnva!="NE", fe cl(cluster_foreign)
		      
} /* percentile */




/***********************************************************************/
/* TABLE XIII: Effect on Productivity by Pre-War Quality of Scientists */
/***********************************************************************/

foreach percentile in  "1" "3" "5" {

cd "$folder\"
use Dataset_7_part1_top`percentile'.dta, clear

	foreach outcome in "pubn_rdc_std" "nom_paper1_belast" "nom_paper1_belast_last2" "pubn_wiw_rdc_std" "pubn_wip_rdc_tot_99th_std" {

	/* Column (1), (3), (5), (7), (9) - Panel A, B, and C */

	set matsize 5000		   
	xtset id 
	xtreg `outcome' FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST FOIN_L_reliance_mnva_L_POST HOME_L_reliance_mnva_L_POST ///
					career_age5_*_d? main_field_foreign_d?_19?? main_field_foreign_d??_19?? main_field_foreign_d?_19??_AL main_field_foreign_d??_19??_AL if AU_block_mnva!="RE" & AU_block_mnva!="NE" & scientist_above_med_prod == 0, fe cl(cluster_foreign)

	/* Column (2), (4), (6), (8), (10) - Panel A, B, and C */
				   
	set matsize 5000		   
	xtset id 
	xtreg `outcome' FOUT_H_reliance_mnva_L_POST FOIN_H_reliance_mnva_L_POST FOUT_L_reliance_mnva_L_POST FOIN_L_reliance_mnva_L_POST HOME_L_reliance_mnva_L_POST ///
					career_age5_*_d? main_field_foreign_d?_19?? main_field_foreign_d??_19?? main_field_foreign_d?_19??_AL main_field_foreign_d??_19??_AL if AU_block_mnva!="RE" & AU_block_mnva!="NE" & scientist_above_med_prod == 1, fe cl(cluster_foreign)
		      
	} /* outcome */
			  
} /* percentile */


